package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;

import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CoreBookingRecordService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreBookingRecord;

@Service("coreBookingRecordService")
public class CoreBookingRecordServiceImpl implements CoreBookingRecordService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCoreBookingRecord(CoreBookingRecord coreBookingRecord) {
		myBatisDAO.insert(coreBookingRecord);
		return true;
	}

	@Override
	public boolean updateCoreBookingRecord(CoreBookingRecord coreBookingRecord) {
		myBatisDAO.update(coreBookingRecord);
		return true;
	}

	@Override
	public boolean deleteCoreBookingRecord(CoreBookingRecord coreBookingRecord) {
		myBatisDAO.delete(coreBookingRecord);
		return true;
	}

	private static final String DELETEBATCH_COREBOOKINGRECORD_BY_IDS="deleteBatchCoreBookingRecordByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_COREBOOKINGRECORD_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CoreBookingRecord getCoreBookingRecord(CoreBookingRecord coreBookingRecord) {
		return (CoreBookingRecord) myBatisDAO.findForObject(coreBookingRecord);
	}

	private static final String FIND_COREBOOKINGRECORD_FOR_LISTS="findCoreBookingRecordForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreBookingRecord> findCoreBookingRecordList() {
		return myBatisDAO.findForList(FIND_COREBOOKINGRECORD_FOR_LISTS, null);
	}

	private static final String FIND_COREBOOKINGRECORD_FOR_PAGES="findCoreBookingRecordForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreBookingRecord> findCoreBookingRecordPage(int pageNum, int pageSize, int crkrdType, String crkrdUser, String crkrdJjArea) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crkrdType", crkrdType);
		hashMap.put("crkrdUser", crkrdUser);
		hashMap.put("crkrdJjArea", crkrdJjArea);
		return myBatisDAO.findForPage(FIND_COREBOOKINGRECORD_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}